# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer: Sören Tempel <soeren+alpine@soeren-tempel.net>
pkgname=cyclone
pkgver=0.35.0
pkgrel=1
pkgdesc="A compiler for application development with R7RS Scheme"
url="https://justinethier.github.io/cyclone/"
# s390x: ck on s390x does not have ck_pr_cas_8 (used by cyclone)
# See: https://github.com/concurrencykit/ck/issues/178
arch="all !s390x"
license="MIT"
makedepends="ck-dev cyclone-bootstrap>=$pkgver"
source="$pkgname-$pkgver.tar.gz::https://github.com/justinethier/cyclone/archive/refs/tags/v$pkgver.tar.gz"

# Since cyclone itself is written in Scheme it needs to be bootstraped.
# For this propose, upstream provides a dedicated cyclone-bootstrap
# repository which includes C files generated by a previous cyclone
# version. We package this as cyclone-init-bootstrap in a separate
# package and compile the original cyclone Scheme sources using it
# initially. From that point onward, we build cyclone using itself.
#
# This is achieved by having both cyclone-init-bootstrap and cyclone
# provide the virtual cyclone-bootstrap package. The latter must have
# the higher provider priority.
#
# See also https://lists.alpinelinux.org/~alpine/devel/%3C33KG0XO61I4IL.2Z7RTAZ5J3SY6%408pit.net%3E
provides="cyclone-bootstrap=$pkgver"
provider_priority=100 # highest

export PREFIX=/usr
export DATADIR=$PREFIX/lib/cyclone

build() {
	# We use a smaller pthread stack size by default,
	# make sure Cyclone configures the stack size manually.
	make CYC_PTHREAD_SET_STACK_SIZE=1
}

check() {
	make test
}

package() {
	DESTDIR="$pkgdir" make install
}

sha512sums="
14226071fa503519b671593d8c67799f6bb730b33c9208bb47e9f91e17e65940765660a69c47b148fb0ecbf6ecb09b71870d8199e9bef30c930eae5bfa5d3f70  cyclone-0.35.0.tar.gz
"
